<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use App\Utils\QueryUtil;

class CreateSysAbout extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('app_tracks', function (Blueprint $table) {
            $table->id();
            $table->string('api', 255)->default('')->comment('访问API');
            $table->string('path', 255)->default('')->comment('访问路径');
            $table->string('user_id', 32)->default('')->comment('用户的ID');
            $table->string('device_id', 60)->default('')->comment('设备id');
            $table->json('user_info')->nullable()->comment('用户的信息');
            $table->double('lng', 13, 10)->default(0)->comment('经度');
            $table->double('lat', 13, 10)->default(0)->comment('纬度');
            $table->json('params')->nullable()->comment('请求参数');
            $table->tinyInteger('plat')->default(1)->comment('访问平台 1清风筹用户端 2清风筹管理后台');
            $table->integer('version')->default(0)->comment('大版本号');
            $table->timestamps();

            $table->index('user_id');
            $table->index('plat');
        }); QueryUtil::tableComment('app_tracks', '接口埋点表');


        // 后台操作记录表 st_ope_logs
        Schema::create('ope_logs', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('adminer', 128)->nullable()->comment('操作人员 例如 马文欢(17614322265)');
            $table->json('data')->nullable()->comment('操作数据/参数');
            $table->string('router')->default('')->comment('访问路径');
            $table->string('kw', 32)->default('')->comment('操作关键词');
            $table->string('ope', 256)->default('')->comment('操作描述');
            $table->timestamps();
        }); QueryUtil::tableComment('ope_logs', '后台操作记录表');
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('sys_about');
    }
}
